home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / wdj0797.zip / TUFFS.ZIP / EXCEPT5.CPP < prev    next >
C/C++ Source or Header  |  1997-04-24  |  683b  |  30 lines

  1. #include <iostream.h>
  2. #include <except.h>
  3. #include <cstring.h>
  4.  
  5. void badFunction(){
  6.   char p[10];
  7.   cout << "Setting p to zero..." << endl;
  8.   memset(p, 0, -10);
  9. }
  10. int main()
  11. {
  12.   DWORD code = 0;
  13.   try
  14.   {
  15.     try
  16.     {
  17.       cout << "Calling badFunction()" << endl;
  18.       badFunction();
  19.       cout << "badFunction() completed without exception" << endl;
  20.     } catch (xmsg &x) {
  21.       cerr << "Exception caught '" << x.why() << "'" << endl;
  22.     } catch (...) {
  23.       cerr << "Unknown exception caught" << endl;
  24.     }
  25.   } __except (code=GetExceptionCode(), 1) {
  26.     cerr << "Unknown system exception " << hex << code << " caught" << endl;
  27.   }
  28.   return 0;
  29. }
  30.